$(function () {
    var productId;
    // 获取传进来的参数？...
    // var productssId;
    var id = window.location.search;
    // console.log(id);
    var productid = id.split("&")[0].split("=")[1];
    var productidss = id.split("&")[1].split("=")[1];
    // console.log(productid + "::" + productidss)
    
    // var productidss = id.split("=")[1];
    // console.log(productid);.

    $.ajax({
        // url: 'http://193.112.55.79:9090/api/getdiscountproduct',
        url: 'http://193.112.55.79:9090/api/getmoneyctrl',

        dataType: 'json',
        data: { "productid": productid },
        success: function (res) {
            console.log(res.result);
            var xx = template("DisList", { "item": res.result[productidss]});
            // console.log(item);
            $('.dis_content').html(xx);
            var comm = template("CommList", { "item": res.result[productidss]});
            $('.dis_commend').html(comm);
        }
    })

    // 评论
    $('.dis_commend').on('click', '.ctrl input', function () {
        var val = $('textarea').val();
        if (!$.trim(val)) {
            alert("评论的内容不能为空！！！");
            return;
        }
        // alert(a);
        console.log($('ul'));
        var curDate = getNowFormatDate();
        console.log(curDate);

        $('ul').prepend($('<li>' + val + '<div><span>' + curDate + '</span>' + '<input type="button" value="删除"/></div></li>'))
        $('ul li:first').hide().slideDown()
        $('textarea').val('')
        console.log(new Date());

        $('li>div>input').on('click', function () {
            $(this).parents('li').remove();
        })
    })
    // 获取当前时间
    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
        return currentdate;
    }




})